from selenium import webdriver
import time

# 初始化浏览器驱动
driver = webdriver.Chrome()
# 先访问淘宝首页（必须先访问，否则添加Cookie会报域名错误）
driver.get("https://www.taobao.com")

# 添加手动获取的Cookie（需替换为实际的name和value）
cookies = [
    {"name": "_m_h5_tk", "value": "d9cfbc4120575956c23127c2f81ec44d_1761906224551"},
    {"name": "_m_h5_tk_enc", "value": "33ccc28e0350fb9b9b5078c092cd687b"},
    {"name": "cookie2", "value": "1b5ed6f2904fb01ca05f07bf4a719366"},
    {"name": "cna", "value": "qV6LIaFkV3UCAXQEYMsXTdzC"},
    {"name": "uc1", "value": "cookie16=URm48syIJ1yk0MX2J7mAAEhTuw%3D%3D&pas=0&cookie14=UoYY4vPiokrhyw%3D%3D&existShop=false&cookie21=WqG3DMC9FxUx&cookie15=WqG3DMC9VAQiUQ%3D%3D"},
    {"name": "lgc", "value": "%5Cu56DB%5Cu53F6%5Cu8349tf%5Cu52A0%5Cu6CB9"},
    {"name": "tracknick", "value": "%5Cu56DB%5Cu53F6%5Cu8349tf%5Cu52A0%5Cu6CB9"},
    {"name": "isg", "value": "BGRk0ges0dONfiUfXe_tEvmlNWJW_YhnsV9HO36F_i_yKQXzpg4b9-yb64kx8cC_"},
]

for cookie in cookies:
    driver.add_cookie(cookie)

# 刷新页面，使Cookie生效
driver.refresh()
time.sleep(5)  # 等待页面加载

time.sleep(5)

# 关闭浏览器
driver.quit()